1. Field of the Invention
The present invention relates to the field of floating point exponent calculations in microprocessors. Specifically, the present invention relates to sharing exponent calculation hardware between a multiplication mantissa unit and a division/square root mantissa unit.
2. Discussion of the Related Art
FIG. 1 shows the IEEE standard floating point data formats. The floating point value definitions of the floating point data formats illustrated in FIG. 1 are described below by equations 1, 2, and 3.
s=sign PA1 e=biased exponent PA1 f=fraction PA1 E=number of bits in exponent (8 for single, 11 for double) PA1 F=number of bits in fraction (23 for single, 52 for double) PA1 B=exponent bias (127 for single, 1023 for double) PA1 Normalized Value (0&lt;e&lt;2.sup.E-1): EQU (-1).sup.s .times.2.sup.e-B .times.1.f (1) PA1 Subnormal Value (e=0): EQU (-1).sup.s .times.2.sup.1-B .times.0.f (2) PA1 Zero: EQU (-1).sup.s .times.0 (3)
A floating point number is analogous to a number in scientific notation with the primary difference being in the IEEE standard, the number is in a base 2 number representation system whereas in standard scientific notation, numbers are represented in base 10. Thus, a standard floating point number has an exponent which represents the binary order of magnitude by which its mantissa must be multiplied. In a normalized floating point number, the implicit leading 1 and all F fraction bits are significant. Therefore, the mantissa of a normalized floating point number always has F+1 significant binary digits in the mantissa.
The IEEE standard for floating point numbers includes two different precisions of floating point numbers. The first type, single precision floating point numbers, have 23 fractional bits and 8 exponent bits; whereas the second type, double precision floating point numbers, have 52 fraction bits and 11 exponent bits,
Binary multiplication of two floating point numbers M1 and M2 is analogous to the multiplication of two base 10 numbers in scientific notation. The mantissas of the operands M1 and M2 are multiplied by each other to produce the resultant mantissa while the exponents E1 and E2 of the operands M1 and M2 are added to produce the resulting exponent Er.
In calculating the resulting exponent Er for a floating point unit, the various cases should be examined. In multiplication, the resultant exponent Er is calculated by the following equation. EQU Er=E1+E2-B-z (4)
In the above equation, if one of the mantissas is subnormal, z equals the number of leading zeros in the subnormal mantissa; otherwise, z is zero. Multiplication is not supported for the case of two subnormal mantissas because the result would always be less than the smallest subnormal number, which is the minimum representable non-zero number.
If Er&lt;1, then the resultant mantissa must be right-shifted by a number of bits so as to counteract setting the resultant exponent to one, which is an exponent's logical minimum value. This quantity, rshift, is calculated by the following equation. EQU rshift=1-Er
There are four output cases in floating point multiplication which warrant discussion. The first case is "real" or "gross" underflow. Gross underflow occurs when Er&lt;1 and rshift&gt;24 for single precision output, and rshift&gt;53 for double precision output. In this case, the resultant mantissa is shifted to the sticky bit position or beyond. The correct output in this case is either zero or the smallest subnormal number, depending upon the rounding mode.
The second case occurs when Er&lt;1 and rshift.ltoreq.24 for single precision outputs, and rshift.ltoreq.53 for double precision outputs. In this case, the correct output is a subnormal number. Therefore, the exponent field of the output is set to zero to indicate that the output is subnormal, but the output exponent value Er is interpreted as being one.
The third case occurs when the output is normal; therefore, Emin.ltoreq.Er.ltoreq.Emax for the given precision. For single and double precision outputs, Emin=1. For single precision outputs, Emax=255, while for double precision outputs, Emax=2047.
The fourth case occurs when the output overflows the range of representable numbers for the given level of precision. Thus, when Er&gt;Emax, the output has overflown and cannot be represented.
If the leading zero detection is not performed and a subnormal operand is allowed, then the calculated resulting exponent is represented by the following equation. EQU Er=E1+E2-B (5)
When Er=1 and the most significant bit of the mantissa is one, the result is normal. When Er=1, the most significant bit of the mantissa is zero, and the fraction is non-zero, the result is subnormal. When Er=1, the most significant bit of the mantissa is zero, and the fraction is zero, gross underflow occurs.
When Er&lt;1, the resulting mantissa needs to be shifted to the right. After such a shifting, the fraction may or may not be all zero, corresponding to gross underflow or a subnormal result, respectively. It is impossible to know whether gross underflow or a subnormal result occurs without knowing how many leading zeros were present in the subnormal operand mantissa.
If Er&gt;1 and one of the operands is subnormal, the resulting mantissa needs to be shifted to the left. After such a shifting, the fraction may or may not be all zero, corresponding to gross underflow or a subnormal result, respectively.
Usually, it is desirable that the result R produced by a multiplication will have the same precision (the same number of significant bits) as each of the operands. If the multiplier produces 2F significant mantissa fraction bits, while the result R can include only F significant mantissa fraction bits, the least significant F mantissa bits output by the multiplier are used only to produce the three rounding bits--the guard, round, and sticky bits--for rounding purposes. The least significant F mantissa bits are then discarded.
To perform a floating point division exponent computation, the resulting exponent Er is calculated by the following equation. EQU Er=E1-E2+B+z (6)
In square root computations, there is only one operand. The operand's exponent is E2. To perform a floating point square root exponent calculation, the resulting exponent is calculated by the following equations. EQU Er=((E2-z-B)/2)+B (7) EQU Er=((E2-z-B-1)/2)+B (8)
Equation 7 applies when the square root operand is normal and its exponent E2 is odd. Because the operand is normal, there are no leading zeros in the mantissa (z=0). Equation 7 also applies when the operand is subnormal (E2=1) and the number of leading zeros is even. In this case, the operand exponent would be odd if the number representation system allowed the representable range to be expanded such that the subnormal number could be written in normal form.
Equation 8 applies when the operand is normal and its exponent E2 is even, thus there are no leading zeros in the mantissa (z=0). Equation 8 also applies when the operand is subnormal (E2=1) and the number of leading zeros is odd. In this case, the operand exponent would be even if the number representation system allowed the representable range to be expanded such that the subnormal number could be written in normal form.
The above equations 7 and 8 can be rewritten using standard algebra by noting that subtracting 1 in the second equation is not needed in integer binary arithmetic since the fraction is truncated anyway. The resulting equation is the following. EQU Er=[(E2-z-B)/2]+B (9)
Equation 9 simplifies to the following. EQU Er=(E2-z+B)/2 (10)
FIG. 2 is a simplified block diagram illustrating how floating point multiplication and division are typically implemented in the prior art. The prior art uses separate exponent calculation units 20 and 21 are used for multiplication and division, respectively, because the exponent computations required for multiplication and division are different.
It is evident from the above discussion that it is desirable to avoid having to implement a separate rounding unit for each floating point mantissa unit.